package com.mpsc.sharding.interceptor;


import com.mpsc.sharding.util.CacheHolder;
import io.micrometer.core.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 对CacheHolder进行清理
 *
 * @author yangzyh
 * @date 2021/1/7 15:50
 */
@Component
public class CacheHolderInterceptor implements HandlerInterceptor {

    @Override
    public void afterCompletion(HttpServletRequest request,
                                HttpServletResponse response,
                                Object handler,
                                @Nullable Exception ex) {
        CacheHolder.remove();
    }

}
